package cn.xiaoxiang.service.impl;

import cn.xiaoxiang.batis.AjaxResult;
import cn.xiaoxiang.domain.Product;
import cn.xiaoxiang.domain.Store;
import cn.xiaoxiang.dto.ProductDto;
import cn.xiaoxiang.feign.StoreService;
import cn.xiaoxiang.mapper.ProductMapper;
import cn.xiaoxiang.service.ProductService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private StoreService storeService;
    @Override
    public AjaxResult add(ProductDto productDto) {
        Product product = new Product();
       product.setPrice(productDto.getPrice());
       product.setName(productDto.getName());
        productMapper.add(product);
        Store store = new Store();
        store.setProductId(product.getId());
        store.setNumber(productDto.getNumber());
        AjaxResult add = storeService.add(store);

        return add;
    }
}
